package com.competitions.videoedithelper.controller;

import com.alibaba.fastjson.JSONObject;
import com.competitions.videoedithelper.entity.ResponseModel;
import com.competitions.videoedithelper.service.impl.UserInfoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Mapler
 */
@CrossOrigin
@RestController
@RequestMapping(value = "/auth")
public class UserInfoController {
    private UserInfoServiceImpl userInfoServiceImpl;

    @Autowired
    public UserInfoController(UserInfoServiceImpl userInfoServiceImpl) {
        this.userInfoServiceImpl = userInfoServiceImpl;
    }

    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public ResponseModel login(@RequestBody JSONObject data, HttpServletRequest request){
        return userInfoServiceImpl.login(data, request);
    }

    @RequestMapping(value = "/register",method = RequestMethod.POST)
    public ResponseModel register(@RequestBody JSONObject data){
        return userInfoServiceImpl.registerAccount(data);
    }


    @RequestMapping(value = "/updateUserInfo",method = RequestMethod.POST)
    public ResponseModel updateUserInfo(@RequestBody JSONObject data){
        return userInfoServiceImpl.updateUserInfo(data);
    }

    @RequestMapping(value = "/registerUserList",method = RequestMethod.GET)
    public ResponseModel registerUserList(){
        return userInfoServiceImpl.registerUserList();
    }

    @RequestMapping(value = "/receiveRegister",method = RequestMethod.GET)
    public ResponseModel receiveRegister(@RequestParam int userId){
        return userInfoServiceImpl.receiveRegister(userId);
    }

    @RequestMapping(value = "/rejectRegister",method = RequestMethod.GET)
    public ResponseModel rejectRegister(@RequestParam int userId){
        return userInfoServiceImpl.rejectRegister(userId);
    }

    @RequestMapping(value = "/selectUsers",method = RequestMethod.GET)
    public ResponseModel selectUsers(){
        return userInfoServiceImpl.selectUsers();
    }

    @RequestMapping(value = "/setUserStatus",method = RequestMethod.GET)
    public ResponseModel setUserStatus(@RequestParam int userId,@RequestParam int status){
        return userInfoServiceImpl.setUserStatus(userId,status);
    }

}
